package com.google.android.gms.internal;

import android.app.Activity;
import android.content.Context;
import android.util.DisplayMetrics;
import android.view.MotionEvent;
import android.view.View;
import java.io.UnsupportedEncodingException;
import java.security.GeneralSecurityException;
import java.util.LinkedList;

public abstract class zzcs implements zzcr {
    protected MotionEvent zzagw;
    protected LinkedList<MotionEvent> zzagx = new LinkedList<>();
    protected long zzagy = 0;
    protected long zzagz = 0;
    protected long zzaha = 0;
    protected long zzahb = 0;
    protected long zzahc = 0;
    protected long zzahd = 0;
    protected long zzahe = 0;
    protected double zzahf;
    private double zzahg;
    private double zzahh;
    protected float zzahi;
    protected float zzahj;
    protected float zzahk;
    protected float zzahl;
    private boolean zzahm = false;
    protected boolean zzahn = false;
    protected DisplayMetrics zzaho;

    protected zzcs(Context context) {
        try {
            if (((Boolean) zzlc.zzio().zzd(zzoi.zzbrr)).booleanValue()) {
                zzbx.zzz();
            } else {
                zzdq.zzar();
            }
            this.zzaho = context.getResources().getDisplayMetrics();
        } catch (Throwable unused) {
        }
    }

    private final String zza(Context context, String str, boolean z, View view, Activity activity, byte[] bArr) {
        zzba zzba;
        int i;
        if (z) {
            try {
                zzba = zza(context, view, activity);
                this.zzahm = true;
            } catch (UnsupportedEncodingException | GeneralSecurityException unused) {
                i = 7;
                return Integer.toString(i);
            } catch (Throwable unused2) {
                i = 3;
                return Integer.toString(i);
            }
        } else {
            zzba = zza(context, (zzax) null);
        }
        if (zzba != null) {
            if (zzba.zzhs() != 0) {
                return zzbx.zza(zzba, str);
            }
        }
        return Integer.toString(5);
    }

    /* access modifiers changed from: protected */
    public abstract long zza(StackTraceElement[] stackTraceElementArr) throws zzdj;

    /* access modifiers changed from: protected */
    public abstract zzba zza(Context context, View view, Activity activity);

    /* access modifiers changed from: protected */
    public abstract zzba zza(Context context, zzax zzax);

    public final String zza(Context context) {
        if (zzds.zzas()) {
            if (((Boolean) zzlc.zzio().zzd(zzoi.zzbrt)).booleanValue()) {
                throw new IllegalStateException("The caller must not be called from the UI thread.");
            }
        }
        return zza(context, (String) null, false, (View) null, (Activity) null, (byte[]) null);
    }

    public final String zza(Context context, String str, View view) {
        return zza(context, str, view, (Activity) null);
    }

    public final String zza(Context context, String str, View view, Activity activity) {
        return zza(context, str, true, view, activity, (byte[]) null);
    }

    public final void zza(int i, int i2, int i3) {
        MotionEvent motionEvent;
        if (this.zzagw != null) {
            this.zzagw.recycle();
        }
        if (this.zzaho != null) {
            motionEvent = MotionEvent.obtain(0, (long) i3, 1, this.zzaho.density * ((float) i), this.zzaho.density * ((float) i2), 0.0f, 0.0f, 0, 0.0f, 0.0f, 0, 0);
        } else {
            motionEvent = null;
        }
        this.zzagw = motionEvent;
        this.zzahn = false;
    }

    /* JADX WARNING: Can't fix incorrect switch cases order */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public final void zza(android.view.MotionEvent r13) {
        /*
            r12 = this;
            boolean r0 = r12.zzahm
            r1 = 0
            if (r0 == 0) goto L_0x0035
            r2 = 0
            r12.zzahb = r2
            r12.zzaha = r2
            r12.zzagz = r2
            r12.zzagy = r2
            r12.zzahc = r2
            r12.zzahe = r2
            r12.zzahd = r2
            java.util.LinkedList<android.view.MotionEvent> r0 = r12.zzagx
            java.util.Iterator r0 = r0.iterator()
        L_0x001b:
            boolean r2 = r0.hasNext()
            if (r2 == 0) goto L_0x002b
            java.lang.Object r2 = r0.next()
            android.view.MotionEvent r2 = (android.view.MotionEvent) r2
            r2.recycle()
            goto L_0x001b
        L_0x002b:
            java.util.LinkedList<android.view.MotionEvent> r0 = r12.zzagx
            r0.clear()
            r0 = 0
            r12.zzagw = r0
            r12.zzahm = r1
        L_0x0035:
            int r0 = r13.getAction()
            switch(r0) {
                case 0: goto L_0x0060;
                case 1: goto L_0x003d;
                case 2: goto L_0x003d;
                default: goto L_0x003c;
            }
        L_0x003c:
            goto L_0x0072
        L_0x003d:
            float r0 = r13.getRawX()
            double r2 = (double) r0
            float r0 = r13.getRawY()
            double r4 = (double) r0
            double r6 = r12.zzahg
            double r6 = r2 - r6
            double r8 = r12.zzahh
            double r8 = r4 - r8
            double r10 = r12.zzahf
            double r6 = r6 * r6
            double r8 = r8 * r8
            double r6 = r6 + r8
            double r6 = java.lang.Math.sqrt(r6)
            double r10 = r10 + r6
            r12.zzahf = r10
            r12.zzahg = r2
            r12.zzahh = r4
            goto L_0x0072
        L_0x0060:
            r2 = 0
            r12.zzahf = r2
            float r0 = r13.getRawX()
            double r2 = (double) r0
            r12.zzahg = r2
            float r0 = r13.getRawY()
            double r2 = (double) r0
            r12.zzahh = r2
        L_0x0072:
            int r0 = r13.getAction()
            r2 = 1
            r4 = 1
            switch(r0) {
                case 0: goto L_0x0116;
                case 1: goto L_0x00df;
                case 2: goto L_0x0086;
                case 3: goto L_0x007e;
                default: goto L_0x007c;
            }
        L_0x007c:
            goto L_0x0146
        L_0x007e:
            long r0 = r12.zzahb
            long r5 = r0 + r2
            r12.zzahb = r5
            goto L_0x0146
        L_0x0086:
            long r2 = r12.zzagz
            int r0 = r13.getHistorySize()
            int r0 = r0 + r4
            long r5 = (long) r0
            long r7 = r2 + r5
            r12.zzagz = r7
            com.google.android.gms.internal.zzdr r13 = r12.zzb((android.view.MotionEvent) r13)     // Catch:{ zzdj -> 0x0146 }
            if (r13 == 0) goto L_0x00a2
            java.lang.Long r0 = r13.zzfl     // Catch:{ zzdj -> 0x0146 }
            if (r0 == 0) goto L_0x00a2
            java.lang.Long r0 = r13.zzajp     // Catch:{ zzdj -> 0x0146 }
            if (r0 == 0) goto L_0x00a2
            r0 = r4
            goto L_0x00a3
        L_0x00a2:
            r0 = r1
        L_0x00a3:
            if (r0 == 0) goto L_0x00b9
            long r2 = r12.zzahd     // Catch:{ zzdj -> 0x0146 }
            java.lang.Long r0 = r13.zzfl     // Catch:{ zzdj -> 0x0146 }
            long r5 = r0.longValue()     // Catch:{ zzdj -> 0x0146 }
            java.lang.Long r0 = r13.zzajp     // Catch:{ zzdj -> 0x0146 }
            long r7 = r0.longValue()     // Catch:{ zzdj -> 0x0146 }
            long r9 = r5 + r7
            long r5 = r2 + r9
            r12.zzahd = r5     // Catch:{ zzdj -> 0x0146 }
        L_0x00b9:
            android.util.DisplayMetrics r0 = r12.zzaho     // Catch:{ zzdj -> 0x0146 }
            if (r0 == 0) goto L_0x00c8
            if (r13 == 0) goto L_0x00c8
            java.lang.Long r0 = r13.zzfj     // Catch:{ zzdj -> 0x0146 }
            if (r0 == 0) goto L_0x00c8
            java.lang.Long r0 = r13.zzajq     // Catch:{ zzdj -> 0x0146 }
            if (r0 == 0) goto L_0x00c8
            r1 = r4
        L_0x00c8:
            if (r1 == 0) goto L_0x0146
            long r0 = r12.zzahe     // Catch:{ zzdj -> 0x0146 }
            java.lang.Long r2 = r13.zzfj     // Catch:{ zzdj -> 0x0146 }
            long r2 = r2.longValue()     // Catch:{ zzdj -> 0x0146 }
            java.lang.Long r13 = r13.zzajq     // Catch:{ zzdj -> 0x0146 }
            long r5 = r13.longValue()     // Catch:{ zzdj -> 0x0146 }
            long r7 = r2 + r5
            long r2 = r0 + r7
            r12.zzahe = r2     // Catch:{ zzdj -> 0x0146 }
            goto L_0x0146
        L_0x00df:
            android.view.MotionEvent r13 = android.view.MotionEvent.obtain(r13)
            r12.zzagw = r13
            java.util.LinkedList<android.view.MotionEvent> r13 = r12.zzagx
            android.view.MotionEvent r0 = r12.zzagw
            r13.add(r0)
            java.util.LinkedList<android.view.MotionEvent> r13 = r12.zzagx
            int r13 = r13.size()
            r0 = 6
            if (r13 <= r0) goto L_0x0100
            java.util.LinkedList<android.view.MotionEvent> r13 = r12.zzagx
            java.lang.Object r13 = r13.remove()
            android.view.MotionEvent r13 = (android.view.MotionEvent) r13
            r13.recycle()
        L_0x0100:
            long r0 = r12.zzaha
            long r5 = r0 + r2
            r12.zzaha = r5
            java.lang.Throwable r13 = new java.lang.Throwable     // Catch:{ zzdj -> 0x0146 }
            r13.<init>()     // Catch:{ zzdj -> 0x0146 }
            java.lang.StackTraceElement[] r13 = r13.getStackTrace()     // Catch:{ zzdj -> 0x0146 }
            long r0 = r12.zza((java.lang.StackTraceElement[]) r13)     // Catch:{ zzdj -> 0x0146 }
            r12.zzahc = r0     // Catch:{ zzdj -> 0x0146 }
            goto L_0x0146
        L_0x0116:
            com.google.android.gms.internal.zzny<java.lang.Boolean> r0 = com.google.android.gms.internal.zzoi.zzbro
            com.google.android.gms.internal.zzog r1 = com.google.android.gms.internal.zzlc.zzio()
            java.lang.Object r0 = r1.zzd(r0)
            java.lang.Boolean r0 = (java.lang.Boolean) r0
            boolean r0 = r0.booleanValue()
            if (r0 == 0) goto L_0x0140
            float r0 = r13.getX()
            r12.zzahi = r0
            float r0 = r13.getY()
            r12.zzahj = r0
            float r0 = r13.getRawX()
            r12.zzahk = r0
            float r13 = r13.getRawY()
            r12.zzahl = r13
        L_0x0140:
            long r0 = r12.zzagy
            long r5 = r0 + r2
            r12.zzagy = r5
        L_0x0146:
            r12.zzahn = r4
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: com.google.android.gms.internal.zzcs.zza(android.view.MotionEvent):void");
    }

    /* access modifiers changed from: protected */
    public abstract zzdr zzb(MotionEvent motionEvent) throws zzdj;

    public void zzb(View view) {
    }
}
